import os
print(os.getcwd())
os.mkdir('dir01')
os.chdir('dir01')
print(os.getcwd())
os.chdir('..')
print(os.getcwd())
def tree_dir(path = '',level = 1):
    if level == 1:
        path = os.getcwd()
        print(path)
    allfile = os.listdir(path)
    for dir in allfile:
        abcDir = os.path.join(os.getcwd(),dir)
        if os.path.isdir(abcDir):
            print('\t' * level + '|' + '_' * level,dir)
            tree_dir(abcDir , level + 1)
        elif os.path.isfile(abcDir):
            print('\t' * level + '|' + '_' * level, dir)
os.rename('dir01','dir02')
dirpath = os.path.join(os.getcwd(),'dir02')
if os.path.isdir(dirpath):
    print('删除目录dir02')
    os.rmdir('dir02')
elif os.path.isfile(dirpath):
    print('删除文件dir02')
    os.remove('dir02')
tree_dir()